- (UIImage *)getSpriteAtOffsetX:(int)x andOffsetY:(int)y
{
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef context = CGBitmapContextCreate(NULL,
                                                 iconWidth, iconHeight, 
                                                 8, 4 * iconWidth, colorSpace
                                                 kCGImageAlphaPremultipliedFirst);
    CGColorSpaceRelease(colorSpace);
    
    CGImageRef copy = CGImageCreateWithImageInRect(spriteSheetImage.CGImage, 
                                                   CGRectMake(x, y, iconWidth, iconHeight));
    if (copy != nil)
    {
        CGContextDrawImage(context, 
                           CGRectMake(0, 0, iconWidth, iconHeight), copy);
        CFRelease(copy);
    }
    
    CGImageRef imageMasked = CGBitmapContextCreateImage(context);
    CGContextRelease(context);
    
    UIGraphicsEndImageContext();
    UIImage *image = [UIImage imageWithCGImage:imageMasked];
    return image;
}